<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p>我在顶部</p>
		<div style="height: 1500px;"></div>
		<a href="index3.html">我在底部</a>
		<input type="button" id="btn" value="回去咯" />
		<script type="text/javascript">
			var bt=document.getElementById("btn");
//			bt.addEventListener("click",function(){
//				var time = setInterval(function(){
//					window.scrollBy(0,-50); 
//						if(window.pageYOffset ==0){
//						   clearInterval(time);
//						}
//					},30)
//				
//			})
			bt.addEventListener("click",function(){
				var scroY =window.pageYOffset;
				console.log(scroY);
				var timer = setInterval(function(){
					scroY-=10;
					window.scrollTo(0,scroY);
					if(scroY<=0){
						clearInterval(timer);
					}
				},1)
			})
		</script>
	</body>
</html>
